package com.edu.ahm.thread;

/**
 *  优先级 范围 1-10
 *  Thread.MIN_PRIORITY = 1
 *  THread.MAX_PRIORITY = 10
 *  Thread.NORM_PRIORITY = 5
 */
/**
 * 改变获取优先级
 *   getPriority() setPriority(int x)
 *
 * */
public class PriorityTest {
    public static void main(String[] args) {
        MyPriority myPriority = new MyPriority();
        Thread t1 = new Thread(myPriority,"t1");
        Thread t2 = new Thread(myPriority,"t2");
        Thread t3 = new Thread(myPriority,"t3");
        Thread t4 = new Thread(myPriority,"t4");
        Thread t5 = new Thread(myPriority,"t5");
        Thread t6 = new Thread(myPriority,"t6");
        // 先设置优先级 再启动  但是 优先级高的不一定每次都先执行 大多数时是的
        // 优先级低 是 概率低
        t1.start();

        t2.setPriority(1);
        t2.start();

        t3.setPriority(4);
        t3.start();

        t4.setPriority(10);
        t4.start();






    }



}

class MyPriority implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"----->"+Thread.currentThread().getPriority());
    }
}